/*
 * Logger.cpp
 *
 *  Created on: Feb 1, 2010
 *      Author: dcrown
 */

#include "Logger.h"
#include <iostream>

using std::cout;
using std::endl;

Logger& Logger::getInstance()
{
	static Logger mLog;
	return mLog;
}
bool Logger::init()
{
	LOG(DEBUG, "Logger initialized");
	return true;
}

bool Logger::shutdown()
{
	//nothing for now
	return true;
}

void Logger::logVA(Level logLevel, const char* function, const char* file, int line, const char* errorString, ...)
{
	//turn the ... into a va_list
	va_list argList;
	//errorString is the last named param
	va_start(argList, errorString);

	char buf[BUF_SIZE];
	vsnprintf(buf, BUF_SIZE, errorString, argList);
	va_end(argList);

	switch (logLevel)
	{
		case FATAL:
			cout << "FATAL:       ";
			break;
		case RECOVERABLE:
			cout << "RECOVERABLE: ";
			break;
		case WARNING:
			cout << "WARNING:     ";
			break;
		case DEBUG:
			cout << "DEBUG:       ";
			break;
	}

	cout << "(" << file << ":" << function << ":" << line << ") " << buf << endl;
	//cout << "             " <<
}

